package com.ymatou.authapp.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.authapp.parameter.BillsLoginIdModifyEventRequestDtoBean;
import com.ymatou.authapp.service.BillsLoginIdModifyEventRequestDtoCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P3;
import com.ymttest.database.mongo.LoginIdUpdateEventHistoryMongoWapper;
/**
*用户在指定时间内登陆失败的次数接口
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_BillsLoginIdModifyEventRequestDto{
	private static BillsLoginIdModifyEventRequestDtoBean billsloginidmodifyeventrequestdtoBean;
	private static BillsLoginIdModifyEventRequestDtoCall billsloginidmodifyeventrequestdtoCall;
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("用户在指定时间内登陆失败的次数接口");
	}

	@Before
	public void caseUp() {
		billsloginidmodifyeventrequestdtoBean=new BillsLoginIdModifyEventRequestDtoBean();
		billsloginidmodifyeventrequestdtoCall=new BillsLoginIdModifyEventRequestDtoCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(billsloginidmodifyeventrequestdtoCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BillsLoginIdModifyEventRequestDto_001() {
		Logger.start(true,"正确返回用户修改用户信息的次数, ActionSource为App说明用户来自手机App注册");
		try {
			billsloginidmodifyeventrequestdtoBean.setUserId(686967);
			billsloginidmodifyeventrequestdtoBean.setLoginId("dmmemo");
			billsloginidmodifyeventrequestdtoBean.setActionSource("App");
			billsloginidmodifyeventrequestdtoCall.setData(billsloginidmodifyeventrequestdtoBean);
			billsloginidmodifyeventrequestdtoCall.callService();			
			LoginIdUpdateEventHistoryMongoWapper loginIdUpdateEventHistoryMongoWapper = new LoginIdUpdateEventHistoryMongoWapper();
			int expectedCount = loginIdUpdateEventHistoryMongoWapper.getModifyLoginIdCount(686967, 1);
			Logger.comment("从数据库查到的修改次数："+expectedCount);
			Logger.verifyEquals(true, billsloginidmodifyeventrequestdtoCall.getSuccess(), "验证是否成功");
			Logger.verifyEquals(expectedCount, billsloginidmodifyeventrequestdtoCall.getModifyLoginIdCount(), "验证用户修改信息的次数");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BillsLoginIdModifyEventRequestDto_002() {
		Logger.start(true,"不输入LoginId，返回用户修改用户信息的次数, ActionSource为App说明用户来自手机App注册");
		try {
			billsloginidmodifyeventrequestdtoBean.setUserId(686967);
			billsloginidmodifyeventrequestdtoBean.setActionSource("App");
			billsloginidmodifyeventrequestdtoCall.setData(billsloginidmodifyeventrequestdtoBean);
			billsloginidmodifyeventrequestdtoCall.callService();			
			LoginIdUpdateEventHistoryMongoWapper loginIdUpdateEventHistoryMongoWapper = new LoginIdUpdateEventHistoryMongoWapper();
			int expectedCount = loginIdUpdateEventHistoryMongoWapper.getModifyLoginIdCount(686967, 1);
			Logger.comment("从数据库查到的修改次数："+expectedCount);
			Logger.verifyEquals(true, billsloginidmodifyeventrequestdtoCall.getSuccess(), "验证是否成功");
			Logger.verifyEquals(expectedCount, billsloginidmodifyeventrequestdtoCall.getModifyLoginIdCount(), "验证用户修改信息的次数");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BillsLoginIdModifyEventRequestDto_003() {
		Logger.start(true,"不输入UserId，返回用户修改用户信息的次数, ActionSource为App说明用户来自手机App注册");
		try {
			billsloginidmodifyeventrequestdtoBean.setLoginId("dmmemo");
			billsloginidmodifyeventrequestdtoBean.setActionSource("App");
			billsloginidmodifyeventrequestdtoCall.setData(billsloginidmodifyeventrequestdtoBean);
			billsloginidmodifyeventrequestdtoCall.callService();			
			Logger.verifyEquals(true, billsloginidmodifyeventrequestdtoCall.getSuccess(), "验证是否成功");
			Logger.verifyEquals(0, billsloginidmodifyeventrequestdtoCall.getModifyLoginIdCount(), "验证用户修改信息的次数");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_BillsLoginIdModifyEventRequestDto_004() {
		Logger.start(false,"不输入ActionSource, 返回用户修改用户信息的次数, ActionSource为App说明用户来自手机App注册");
		try {
			billsloginidmodifyeventrequestdtoBean.setUserId(686967);
			billsloginidmodifyeventrequestdtoBean.setLoginId("dmmemo");
			billsloginidmodifyeventrequestdtoCall.setData(billsloginidmodifyeventrequestdtoBean);
			billsloginidmodifyeventrequestdtoCall.callService();			
			Logger.verifyEquals(true, billsloginidmodifyeventrequestdtoCall.getSuccess(), "验证是否成功");
			Logger.verifyEquals(0, billsloginidmodifyeventrequestdtoCall.getModifyLoginIdCount(), "验证用户修改信息的次数");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_BillsLoginIdModifyEventRequestDto_005() {
		Logger.start(true,"输入不存在的UserId和正确的LoginId, 返回用户修改用户信息的次数, ActionSource为App说明用户来自手机App注册");
		try {
			billsloginidmodifyeventrequestdtoBean.setUserId(123666666);
			billsloginidmodifyeventrequestdtoBean.setLoginId("dmmemo");
			billsloginidmodifyeventrequestdtoBean.setActionSource("App");
			billsloginidmodifyeventrequestdtoCall.setData(billsloginidmodifyeventrequestdtoBean);
			billsloginidmodifyeventrequestdtoCall.callService();			
			Logger.verifyEquals(true, billsloginidmodifyeventrequestdtoCall.getSuccess(), "验证是否成功");
			Logger.verifyEquals(0, billsloginidmodifyeventrequestdtoCall.getModifyLoginIdCount(), "验证用户修改信息的次数");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_BillsLoginIdModifyEventRequestDto_006() {
		Logger.start(true,"输入不存在的LoginId和正确的UserId, 返回用户修改用户信息的次数, ActionSource为App说明用户来自手机App注册");
		try {
			billsloginidmodifyeventrequestdtoBean.setUserId(686967);
			billsloginidmodifyeventrequestdtoBean.setLoginId("test007");
			billsloginidmodifyeventrequestdtoBean.setActionSource("App");
			billsloginidmodifyeventrequestdtoCall.setData(billsloginidmodifyeventrequestdtoBean);
			billsloginidmodifyeventrequestdtoCall.callService();			
			LoginIdUpdateEventHistoryMongoWapper loginIdUpdateEventHistoryMongoWapper = new LoginIdUpdateEventHistoryMongoWapper();
			int expectedCount = loginIdUpdateEventHistoryMongoWapper.getModifyLoginIdCount(686967, 1);
			Logger.comment("从数据库查到的修改次数："+expectedCount);
			Logger.verifyEquals(true, billsloginidmodifyeventrequestdtoCall.getSuccess(), "验证是否成功");
			Logger.verifyEquals(expectedCount, billsloginidmodifyeventrequestdtoCall.getModifyLoginIdCount(), "验证用户修改信息的次数");
		
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_BillsLoginIdModifyEventRequestDto_007() {
		Logger.start(false, "输入错误的LoginId和错误的UserId, 返回用户修改用户信息的次数, ActionSource为App说明用户来自手机App注册");
		try {
			billsloginidmodifyeventrequestdtoBean.setUserId(123666666);
			billsloginidmodifyeventrequestdtoBean.setLoginId("test007");
			billsloginidmodifyeventrequestdtoBean.setActionSource("App");
			billsloginidmodifyeventrequestdtoCall.setData(billsloginidmodifyeventrequestdtoBean);
			billsloginidmodifyeventrequestdtoCall.callService();			
			Logger.verifyEquals(true, billsloginidmodifyeventrequestdtoCall.getSuccess(), "验证是否成功");
			Logger.verifyEquals(0, billsloginidmodifyeventrequestdtoCall.getModifyLoginIdCount(), "验证用户修改信息的次数");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	@Ignore//需要确认需求，是否存在传入不存在的ActionSource的情况
	public void Tc_BillsLoginIdModifyEventRequestDto_008() {
		Logger.start(false,"输入不存在的ActionSource, 返回用户修改用户信息的次数, ActionSource为App说明用户来自手机App注册");
		try {
			billsloginidmodifyeventrequestdtoBean.setUserId(686967);
			billsloginidmodifyeventrequestdtoBean.setLoginId("dmmemo");
			billsloginidmodifyeventrequestdtoBean.setActionSource("aaa");
			billsloginidmodifyeventrequestdtoCall.setData(billsloginidmodifyeventrequestdtoBean);
			billsloginidmodifyeventrequestdtoCall.callService();			
			Logger.verifyEquals(true, billsloginidmodifyeventrequestdtoCall.getSuccess(), "验证是否成功");
			Logger.verifyEquals(0, billsloginidmodifyeventrequestdtoCall.getModifyLoginIdCount(), "验证用户修改信息的次数");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}